{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Midterm Exam - Due October 10th, 2:00PM\n",
    "\n",
    "## (155 Points)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### CELL 0 ###\n",
    "# \n",
    "# REMEMBER: YOU ARE NOT ALLOWED TO WORK IN GROUPS OF ANY SIZE.\n",
    "# ALL QUESTIONS MUST BE SOLVED ENTIRELY ON YOUR OWN!\n",
    "# \n",
    "# Please enter your name below:\n",
    "# 1.) Angela Overlack\n",
    "##############"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Question 1: Indexing and Slicing (20 Points)\n",
    "You are provided with a variable called `randlist`.  Each time that the code is run, `randlist` will be regenerated with a random length.  Your task is to make all of the print statements to print the correct output by using indexing and/or slicing on the `randlist` variable that appears in that line.\n",
    "\n",
    "### Constraints\n",
    "1. All of the list manipulations must be done only using *indexing* (i.e., `[]`) and/or  *slicing* (i.e., `[::]`, `[:]`, etc).\n",
    "2. You must not change the `randlist` variable.\n",
    "3. You cannot create any additional variables.\n",
    "4. The only modifications that you can make to the code is to add indexing and/or slicing to `randlist`.\n",
    "\n",
    "### Hints\n",
    "1. Remember that slicing can have up to three values: a *start* value, an *end* value, and a *skip* value.\n",
    "2. Remember that these numbers can be negative and and positive.\n",
    "3. Remember that you don't always need all of the values.\n",
    "4. Remember that indexing is 0-based.\n",
    "\n",
    "### Example\n",
    "If the code is:\n",
    "```\n",
    "print(\"\\nThe third element of randlist is:\")\n",
    "print(randlist)\n",
    "```\n",
    "You should change it to:\n",
    "```\n",
    "print(\"\\nThe third element of randlist is:\")\n",
    "print(randlist[2])\n",
    "```\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "The initial list is:\n",
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]\n",
      "\n",
      "The fifth element of randlist is:\n",
      "4\n",
      "\n",
      "A list containing only the fifth element of randlist is:\n",
      "4\n",
      "\n",
      "A list containing the 2nd through 12th elements of randlist is:\n",
      "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n",
      "\n",
      "The last element of randlist is:\n",
      "22\n",
      "\n",
      "A list containing the last element of randlist is:\n",
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]\n",
      "\n",
      "A list containing the last 5 elements of randlist is:\n",
      "[18, 19, 20, 21, 22]\n",
      "\n",
      "A list containing everything except the last 5 elements of randlist is:\n",
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\n",
      "\n",
      "A list containing the even elements of randlist is:\n",
      "[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]\n",
      "\n",
      "A list containing the odd elements of randlist is:\n",
      "[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n",
      "\n",
      "A list containing the elements of randlist in reverse order is:\n",
      "[22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n"
     ]
    }
   ],
   "source": [
    "### Question 1 ###\n",
    "import random\n",
    "randlist = []\n",
    "for x in range(random.randint(15,23)):\n",
    "    randlist.append(x)\n",
    "print(\"\\nThe initial list is:\")\n",
    "print(randlist)\n",
    "\n",
    "### Write your code below this line ###\n",
    "\n",
    "print(\"\\nThe fifth element of randlist is:\")\n",
    "print(randlist[4])\n",
    "\n",
    "print(\"\\nA list containing only the fifth element of randlist is:\") #what the difference between this and before\n",
    "print(randlist[4])\n",
    "\n",
    "print(\"\\nA list containing the 2nd through 12th elements of randlist is:\")\n",
    "print(randlist[1:12])\n",
    "\n",
    "print(\"\\nThe last element of randlist is:\")\n",
    "print(randlist[-1])\n",
    "\n",
    "print(\"\\nA list containing the last element of randlist is:\") #what the difference between this and before\n",
    "print(randlist) #just the whole list?\n",
    "\n",
    "print(\"\\nA list containing the last 5 elements of randlist is:\")\n",
    "print(randlist[-5:]) \n",
    "\n",
    "print(\"\\nA list containing everything except the last 5 elements of randlist is:\")\n",
    "print(randlist[:-5])\n",
    "\n",
    "print(\"\\nA list containing the even elements of randlist is:\")\n",
    "print(randlist[::2])\n",
    "\n",
    "print(\"\\nA list containing the odd elements of randlist is:\")\n",
    "print(randlist[1::2])\n",
    "\n",
    "print(\"\\nA list containing the elements of randlist in reverse order is:\")\n",
    "print(randlist[::-1])\n",
    "\n",
    "### Do not change the code below this line ###"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Question 2: List Comprehensions (20 Points)\n",
    "\n",
    "Create the lists described below using List comprehensions.  The instructions for each part is found in the corresponding `print()` statement.\n",
    "\n",
    "### Constraints\n",
    "1. Do not add any additional lines of code.\n",
    "2. Your code should only be entered between the square brackets `[]`.\n",
    "\n",
    "### Hints\n",
    "1. Remember that List comprehensions can be filtered (*e.g.,* `[for..in..if]`).\n",
    "2. The `string` library is imported, so you can use its constants.\n",
    "3. The `math` library is imported.\n",
    "4. The variable `gettysburg_address` is provided for you, which is needed for some (but not all) questions.\n",
    "\n",
    "### Example\n",
    "If the code is:\n",
    "```\n",
    "print(\"\\nA list containing the even numbers 0 through 30:\")\n",
    "print([])\n",
    "```\n",
    "You should change it to:\n",
    "```\n",
    "print(\"\\nA list containing the even numbers 0 through 30:\")\n",
    "print([x for x in range(0, 31, 2)])\n",
    "```\n",
    "Or:\n",
    "```\n",
    "print(\"\\nA list containing the even numbers 0 through 30:\")\n",
    "print([x for x in range(31) if not x % 2])\n",
    "```\n",
    "Or some other equivalent list comprehension (there are several other alternatives)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-47-6958fe26439c>, line 15)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  File \u001b[0;32m\"<ipython-input-47-6958fe26439c>\"\u001b[0;36m, line \u001b[0;32m15\u001b[0m\n\u001b[0;31m    print([n>1  for n in asteriks print \"*\" *n])\u001b[0m\n\u001b[0m                                      ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "### Question 2 ###\n",
    "import string\n",
    "import math\n",
    "gettysburg_address = \"Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the people, for the people, shall not perish from the earth.\"\n",
    "### Write your code below this line ###\n",
    "\n",
    "# Example output starts:\n",
    "# ['A', 'B', ...\n",
    "print(\"\\nA list containing all uppercase letters of the alphabet:\")\n",
    "print([string.ascii_uppercase])\n",
    "\n",
    "# Example output starts:\n",
    "# ['*', '**', '***', ...\n",
    "print(\"\\nA list of 25 strings, with each string containing n + 1 asterisks, where n is the index of the string within the list:\")\n",
    "print([n>1  for n in asteriks print \"*\" *n])\n",
    "\n",
    "# Example output starts:\n",
    "# [(0.0, 0.0), (0.01, 0.009999833334166664), ...\n",
    "print(\"\\nA list of tuples (x, sin(x)) for values of x 0 through .5 in increments of .01:\")\n",
    "print([])\n",
    "\n",
    "# Example output starts:\n",
    "# [(0, 32.0), (1, 33.8), ...\n",
    "print(\"\\nA list containing the tuple (x, F(x)), where x represents the temperature 0 to 100 degrees Celcius, and F(x) is that temperature converted to Farenheit using the standard formula:\")\n",
    "print([])\n",
    "\n",
    "# Example output starts:\n",
    "# [(10, 100, 1000), (11, 121, 1331), ...\n",
    "print(\"\\nA list containing the tuples of x, its square, and its cube, for values of x 10 through 20:\")\n",
    "print([])\n",
    "\n",
    "# Example output starts:\n",
    "# [0, 4, ...\n",
    "print(\"\\nA list containing the squares of x, 0 through 25, but only if the square is divisible by 3 or 4:\")\n",
    "print([])\n",
    "\n",
    "# Example output starts:\n",
    "# ['seven', 'conceived', ...\n",
    "print(\"\\nA list of words in the Gettysburg Address, in which each word has at least two e's:\")\n",
    "print([])\n",
    "\n",
    "# Example output starts:\n",
    "# ['o', 'u', 'o', 'e', \n",
    "print(\"\\nA list of all the vowels (aeiou) in the Gettysburg Address (i.e., filter out the consonants) in the order that they appear:\")\n",
    "print([])\n",
    "\n",
    "# Example output starts:\n",
    "# ['and', 'ago', ...\n",
    "print(\"\\nA list of words from the Gettysburg Address that contains less than 4 letters ('--' is ok):\")\n",
    "print([])\n",
    "\n",
    "# Example output starts:\n",
    "# ['AND', 'AGO', ...\n",
    "print(\"\\nA list of words from the Gettysburg Address that contains less than 4 letters, but also has all words converted to uppercase and '--' is filtered out:\")\n",
    "print([])\n",
    "\n",
    "### Do not change the code below this line ###"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Question 3: Function and Tuple (20 Points)\n",
    "Write a function called `computetime(seconds)` which takes in a number, in seconds, and returns a 4-tuple containing the number of days, hours, minutes, and seconds represented by the input number of seconds.\n",
    "\n",
    "### Constraints\n",
    "1. You may only modify the interior of the `computetime()` function.\n",
    "2. You cannot access any outside libraries to perform the computations.\n",
    "\n",
    "### Hints\n",
    "1. Replace the `return (0,0,0,0)` with the correct calculations.\n",
    "2. Remember math tools such as `//` (integer division) and `%` (modulo).\n",
    "\n",
    "### Example\n",
    "One of the lines of output will be this:\n",
    "```\n",
    "1000000 seconds is equivalent to 11 day(s), 13 hour(s), 46 minute(s), and 40 second(s).\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### Question 3 ###\n",
    "### Write your code below this line ###\n",
    "def computetime(seconds):\n",
    "    return 0,0,0,0\n",
    "\n",
    "### Do not change the code below this line ###\n",
    "for secs in [10**(i / 2.5) for i in range(20)]:\n",
    "    days, hours, minutes, seconds = computetime(secs)\n",
    "    print(\"%d seconds is equivalent to %d day(s), %d hour(s), %d minute(s), and %d second(s).\" % (secs, days, hours, minutes, seconds))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Question 4: Functions and Loops (20 Points)\n",
    "\n",
    "Write a function called `inboth(s1, s2)` which takes two strings and returns a string containing the characters that are in both strings.\n",
    "\n",
    "### Constraints\n",
    "1. The value that is returned by the function must be a string.\n",
    "1. The returned string must not contain any duplicate letters.\n",
    "2. The returned string must be ordered by ASCII value.\n",
    "\n",
    "### Hints\n",
    "1. Remember the `in` operator.\n",
    "2. Remember the `sorted()` function.\n",
    "3. Your function should handle all characters, and not just letters or numbers.\n",
    "4. Sample output:\n",
    "\n",
    "```\n",
    "String 1: \"Bert and Ernie\"\n",
    "String 2: \"Batman and Robin\"\n",
    "Characters in common: \" Badint\"\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### Question 4 ###\n",
    "### Write your code below this line ###\n",
    "def inboth(s1, s2):\n",
    "    pass\n",
    "\n",
    "### Do not change the code below this line ###\n",
    "\n",
    "# Set up pairs of phrases to test, using a list of tuples.\n",
    "pairs = [(\"Bert and Ernie\",\"Batman and Robin\"),\n",
    "         (\"Hello, my dear friend!\", \"What?!?\"),\n",
    "         (\"The quick brown fox jumped over the lazy dog.\", \"Dr. Livingstone, I presume\"),\n",
    "         (\"8675309\", \"3.14159\"),\n",
    "         (\"What is the answer to this question?\", \"\"),\n",
    "         (\"Where's Waldo?\", \"Where's Waldo?\"),\n",
    "         (\"How much wood would a woodchuck chuck if a woodchuck could chuck wood?\", \"A woodchuck would chuck all the wood he could if a woodchuck could chuck wood.\")]\n",
    "\n",
    "# Test the pairs of words.\n",
    "for word1, word2 in pairs:\n",
    "    print('String 1: \"%s\"\\nString 2: \"%s\"\\nCharacters in common: \"%s\"\\n' % (word1, word2, ''.join(sorted(inboth(word1, word2)))))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Question 5: Functions and Loops (30 Points)\n",
    "Write a function called `printTree(size)` that prints out a tree of the requested size.\n",
    "\n",
    "### Constraints\n",
    "  1. The printed pattern is mathematically related to the `size` variable that is passed in to the function.\n",
    "  2. The length of the \"trunk\" is also mathematically related to the `size` variable.\n",
    "  3. Your output should match the sample output for the sizes given.\n",
    "  \n",
    "### Example Output\n",
    "\n",
    "```\n",
    "Printing a tree of size 3.\n",
    "  ^  \n",
    " ^^^ \n",
    "^^^^^\n",
    "  |  \n",
    "\n",
    "Printing a tree of size 4.\n",
    "   ^   \n",
    "  ^^^  \n",
    " ^^^^^ \n",
    "^^^^^^^\n",
    "   |   \n",
    "   |   \n",
    "\n",
    "Printing a tree of size 5.\n",
    "    ^    \n",
    "   ^^^   \n",
    "  ^^^^^  \n",
    " ^^^^^^^ \n",
    "^^^^^^^^^\n",
    "    |    \n",
    "    |    \n",
    "\n",
    "Printing a tree of size 6.\n",
    "     ^     \n",
    "    ^^^    \n",
    "   ^^^^^   \n",
    "  ^^^^^^^  \n",
    " ^^^^^^^^^ \n",
    "^^^^^^^^^^^\n",
    "     |     \n",
    "     |     \n",
    "     |     \n",
    "\n",
    "Printing a tree of size 7.\n",
    "      ^      \n",
    "     ^^^     \n",
    "    ^^^^^    \n",
    "   ^^^^^^^   \n",
    "  ^^^^^^^^^  \n",
    " ^^^^^^^^^^^ \n",
    "^^^^^^^^^^^^^\n",
    "      |      \n",
    "      |      \n",
    "      |      \n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### Question 5 ###\n",
    "### Write your code below this line ###\n",
    "def printTree(size):\n",
    "    pass\n",
    "\n",
    "\n",
    "### Do not change the code below this line ###\n",
    "for s in range(3, 15):\n",
    "    print(f\"Printing a tree of size {s}.\")\n",
    "    printTree(s)\n",
    "    print()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Question 6: Code Minification (45 Points)\n",
    "\n",
    "Re-write the following code so that it fits on as few lines as possible.\n",
    "\n",
    "The point of this section is for you to be able to understand the code that someone else has written, as well as to express the same idea in a concise manner.\n",
    "\n",
    "Partial credit will be given for improved (but perhaps not optimal) solutions.\n",
    "\n",
    "We are not grading efficiency, but correctness of the code with respect to any input values.\n",
    "\n",
    "### Example:\n",
    "\n",
    "If the code is:\n",
    "\n",
    "```\n",
    "nums = \"\"\n",
    "for x in range(1000):\n",
    "    if int(x ** .5) == x ** .5:\n",
    "        nums += f\"\\n{str(x)}\"\n",
    "print(nums)\n",
    "```\n",
    "\n",
    "You could write:\n",
    "\n",
    "```\n",
    "print(\"\\n\".join([str(x) for x in range(1000) if int(x ** .5) == x ** .5]))\n",
    "```\n",
    "\n",
    "**Note:** This list in this example happens to be the list of perfect squares.  With this realization, you can write an even simpler solution.  The problems below are not as straightforward.  This particular example also does not have any input variables, either.  The problems below, however, do have an input variable.  Your solution must use that variable with either the supplied value, or any other value that we substitute in.  In other words, your solution must adapt to whatever value the supplied variable is set to, just as the \"Original Code\" section does."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 6a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### Question 6a ###\n",
    "gettysburg_address = \"Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the people, for the people, shall not perish from the earth.\"\n",
    "### Original Code\n",
    "### Do not change the code in this cell\n",
    "\n",
    "gba = gettysburg_address.upper()\n",
    "sortedWords = sorted(gba.split(), key=len, reverse=True)\n",
    "wordlist = []\n",
    "for word in sortedWords:\n",
    "    wordlist.append((word, len(word)))\n",
    "print(wordlist)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### Question 6a Rewrite ###\n",
    "gettysburg_address = \"Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the people, for the people, shall not perish from the earth.\"\n",
    "### This can be re-written in as little as 1 line.\n",
    "### Write your code below this line.\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 6b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### Question 6b ###\n",
    "message = \"Rally sons of Notre Dame!!!\"\n",
    "### Original Code\n",
    "### Do not change the code in this cell\n",
    "\n",
    "words = message.split()\n",
    "maxlen = 0\n",
    "for word in words:\n",
    "    maxlen = max(maxlen, len(word))\n",
    "print('*' * (maxlen + 4))\n",
    "for word in words:\n",
    "    print(f\"* {word:^{maxlen}} *\")\n",
    "print('*' * (maxlen + 4))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### Question 6b Rewrite ###\n",
    "message = \"Rally sons of Notre Dame!!!\"\n",
    "### This can be re-written in as little as 1 line.\n",
    "### Write your code below this line.\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 6c\n",
    "Your re-written code will be in the `printRhombus()` function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### Question 6c ###\n",
    "### Original Code\n",
    "### Do not change the code in this cell\n",
    "def printRhombus(size, times):\n",
    "    for line in range(size + 1):\n",
    "        for time in range(times):\n",
    "            print(f\"{'#'*line:<{size}}\", end=\" \")\n",
    "        print()\n",
    "    for line in range(size - 1, 0, -1):\n",
    "        for time in range(times):\n",
    "            print(f\"{'#'*line:>{size}}\", end=\" \")\n",
    "        print()\n",
    "\n",
    "\n",
    "### Do not change the code below this line ###\n",
    "for s in range(1, 8):\n",
    "    print(f\"Printing {s + 1} Rhombus(es) of size {s}.\")\n",
    "    printRhombus(s, s + 1)\n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "### Question 6c Rewrite ###\n",
    "\n",
    "### This function body can be re-written in as little as 1 line (replacing `pass`).\n",
    "### Write your code below this line.\n",
    "def printRhombus(size, times):\n",
    "    pass\n",
    "\n",
    "\n",
    "### Do not change the code below this line ###\n",
    "for s in range(1, 8):\n",
    "    print(f\"Printing {s + 1} Rhombus(es) of size {s}.\")\n",
    "    printRhombus(s, s + 1)\n",
    "    print()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
